<template>
    <div>
      <comment-message @handleReply="handleReply" :commentList="comments"></comment-message>
      <comment-area :articleId="articleId" @reload="reload" :parentMsgId="replyMsgId" :replyMsgUsername="replyMsgUsername" :parentAvatar="parentAvatar"></comment-area>
    </div>
  </template>
  
  <script>
  import CommentMessage from "./CommentMessage";
  import CommentArea from "./CommentArea";
  import {getArticleComment} from '@/api/request'
  
  export default {
    name: "Message",
    props: {
      articleId: String
    },
    components: {
      CommentMessage,
      CommentArea
    },
    data() {
      return {
        comments: [],
        replyMsgId: "",
        replyMsgUsername: "",
        parentAvatar:''
      };
    },
    mounted() {
      this.handleGetArticleComment()
    },
    methods: {
      //获取文章对应所有评论
      handleGetArticleComment(){
        console.log(this.articleId,'bbbb')
        getArticleComment({"articleId":this.articleId}).then(res=>{
          if(res.data.status===0){
            this.comments=res.data.data
            console.log('haha',this.comments)
          }
        })
      },
      handleReply(data) {
        this.replyMsgId = data.msgId;
        this.replyMsgUsername = data.msgUsername;
        this.parentAvatar=data.msgAvatar
      },
      reload() {
        // this.$emit("reload")
        this.handleGetArticleComment()
      }
    }
  };
  </script>
  
  <style>
  </style>
  